1. Field of the Invention
This invention relates to the field of computer programming languages. Specifically, this invention includes a method, apparatus, and computer program product for increasing a compiler's performance on subsequent compilations of a source program.
2. Background
Compilers are programs that execute in a computer to transform a source program represented in one language (often in a human readable form) to an equivalent program in a target language. The target language is directed to an Application Binary Interface (ABI). The ABI is generally defined by the computer hardware and operating system. The computer uses the target language to perform the operations specified by the source program. Sometimes the ABI is defined for an abstract environment called a virtual machine. An implementation of a virtual machine is a program, that executes on the hosting computer, that implements an ABI other than the hosting computer's ABI.
Many compilers provide an optimization capability that evaluates the structure of the source program to improve the execution speed of the compiled program when the computer executes the target language. The compiler's optimization operations are often compute intensive. Thus, enabling the compiler's optimization features generally increases the time required to compile the source program. This increased compilation time increases the time required for a developer to change and compile the source program, and test the program resulting from the target language--thus lengthening the program's development cycle.
During most of the program development process, only a small portion of the source program changes between subsequent compilations. However, prior art program development systems often recompile unchanged portions of a source program during subsequent compilations. Although many program development systems detect when a given source module needs to be compiled, a change in only one compilable unit in the source module still causes the entire module to be recompiled. A "compilation unit" is a portion of the source program that is compiled as a unit (for example, but without limitation, a function, method or procedure, or even a statement).
Many traditional static compilers generate the target language in the form of multiple object modules. The object modules are linked together to create an executable file that can be loaded into the computer's memory and executed without invoking the compiler. However, dynamic compilers compile the source program every time the program is executed. Thus as the program executes, uncompiled compilation units are compiled just prior to their first execution. This characteristic means that programming environments that use dynamic compilers have a longer program startup delay than do traditional programming environments using static compilers. This startup delay is a function of the performance of the compiler. To reduce the startup delay, most dynamic compilers do little if any optimizations during the program's startup period.
In addition, adaptive compilers (those dynamic compilers that optimize portions of the executing program depending on performance characteristics determined from run-time usage information) still need to perform the optimization function as rapidly as possible. Otherwise, the time required to optimize the compilation unit will be greater than the time saved by executing the optimized code.
Furthermore, it is difficult to debug a program that uses adaptive compilation because often the optimization decisions are not completely reproducible between separate executions of the program. Thus, mistakes in the compiler optimization code are very difficult to debug.
One prior art approach to improving the startup delay for a dynamically compiled program is to save a copy of the compiled program to disk--a core dump (for example as was done in the SELF programming environment). This allows the state of the executing program to be saved. Subsequent executions of the program, starting from the saved state, can be invoked by loading the core dump into the computer's memory and resuming execution of the program. The problem with this approach is that subsequent executions of the program may not have the same performance characteristics as the saved program. Therefor, the previous optimization decisions may no longer be valid. Yet another problem is that a core dump is executed on an identically configured computer/operating system combination. Thus, the core dump image may not be useable when the operating system is updated or if the core dump image is transferred from one computer to another.
To summarize, one problem with the prior art is that static compilers need improved performance to shorten the development cycle. Another problem is that dynamic compilers need high performance to reduce the startup delay for a dynamically compiled application. Another problem is that it is very difficult to recreate the state of a program executing with an adaptive compiler because the exact sequence of optimizations (which depends on run-time feedback) is difficult to recreate. Further, the prior art techniques used to improve the startup delay of a program compiled by an adaptive compiler (such as the core dump approach) are system dependent and not portable to other systems.